<!--基本业务查询-大小额基本业务查询-->
<template>
  <div class="app-container">
    <ht-search-form
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
    >
    </ht-search-form>
    <ht-table
      ref="dataTable"
      rowKey="id"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="120" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    toViewDetail(scope.row);
                  },
                }
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <query-detail-dialog ref="queryDetailDialog" :dictMap="dictMap"></query-detail-dialog>
  </div>
</template>
<script>

import { apiUrlConfig } from "@/api/cnaps/baseBiz/inquire/batch/index";
import QueryDetailDialog from "./components/Details";
import { listPageMixin } from "@/libs/listPageMixin";
export default {
  name: "baseBizInqBatchIndex",
  mixins: [listPageMixin],
  components: {
    QueryDetailDialog,
  },
  data() {
    return {
      reqConfig: apiUrlConfig,
      //数据字典
      searchFormDictList: [
        'Cnaps2Dict.CP2_STATUS',
        'DRCTCODE',
        "Cnaps2Dict.CP2_BRNO",
        "PKG_STATUS",
        "PROCESSSTATUS",
        "CP2_STATUS",
        "COM_STATUS",
        "BUDGETLEVELCODE",
        "INDICATOR_CODE",
        "BUDGETTYPECODE",
        "DEPT_CODE",
        "CURCD",
        "DEBT_BANK_TYPE",
        "CBFLAG",
        "TXN_SOURCE",
        "NOTE_TYPE",
        "DFT_CTGY",
        "BANK_NOTE_TYPE",
        "TXN_STATUS",
        "Cnaps2Dict.PKG_NO_BEPS",
        "SYSTEMCODE",
        "RegionId"





      ],
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        id: "",
        cpgdate1: '',
        cpgdate2: '',
        workdate1: '',
        workdate2: '',
        pkgNo: "",
      },
      formOptions: [],
      tableBindColumns: [
        { label: `内部机构号`, prop: "brno", dictCode: "Cnaps2Dict.CP2_BRNO", width: "150" },
        { label: `批次号`, prop: "id", width: "160" },
        { label: `CPG日期`, prop: "vdate", width: "120" },
        { label: `工作日期`, prop: "workdate" },
        {
          label: `来往账标志`,
          prop: "drct",
          width: "100",
          dictCode: "Cnaps2Dict.DRCTCODE",
          sortable: false,
        },
        { label: `报文标识号`, prop: "pkgId", width: 120 },
        { label: `报文类型`, prop: "pkgNo", formatter: (row) => {
            if(!row.pkgNo) {
              return '-'
            }
            return `${row.pkgNo + '-' + row.pkgNoDesc}`;
          }
        },
        {
          label: `发起清算行行号`,
          prop: "directSender",
          width: 160,
          sortable: false,
        },
        {
          label: `接收清算行行号`,
          prop: "directRecver",
          width: 160,
          sortable: false,
        },
        {
          label: `明细业务总笔数`,
          prop: "dtlNum",
          width: 160,
          sortable: false,
        },
        {
          label: `明细业务总金额`,
          prop: "dtlAmount",
          width: 160,
          type: 'price',
          sortable: false,
        },
        {
          label: `通讯状态`,
          prop: "status",
          width: 160,
          dictCode: 'Cnaps2Dict.COM_STATUS',
          sortable: false,
        },
        {
          label: `中心状态`,
          prop: "procStatus",
          width: 160,
          dictCode: 'Cnaps2Dict.PROCESSSTATUS',
          sortable: false,
        }
      ],
    };
  },
  mounted() {
    this.formOptions = [
      {
        type: "input",
        prop: "id",
        defaultAttr: {
          label: "批次号",
          placeholder: "请输入批次号",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "cpgdate1",
          endTimeName: "cpgdate2",
        },
        defaultAttr: {
          label: "CPG日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate1",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          label: "工作日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dict",
        dict: "Cnaps2Dict.PKG_NO_BEPS",
        prop: "pkgNo",
        defaultAttr: {
          label: "报文类型",
          placeholder: "请选择报文类型",
        },
      },
    ];
  },
  methods: {
    beforeSearchCallback() {
      // 搜索按钮之前先执行
      this.queryParams.amount1 = this.$refs.amountRangeSearch.getAmount1();
      this.queryParams.amount2 = this.$refs.amountRangeSearch.getAmount2();
    },
    clearCallBack() {
      let that = this;
      return new Promise(function (resolve, reject) {
        that.$refs.amountRangeSearch.clearAmount();
        that.queryParams.amount1 = "";
        that.queryParams.amount2 = "";
      });
    },
    editComplete(state) {
      console.log("editComplete", state);
      if (state == true) {
        this.getList();
      }
    },
    /** todo 查询当天操作员的交易记录 */
    getList() {
      this.doQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /*查看明细*/
    toViewDetail(row) {
      console.log("this.$refs.queryDetailDialog", this.$refs);
      this.$refs.queryDetailDialog.show(row.id, row.pkgNo);
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
